<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>列表循环渲染</title>
  </head>
  <body>
    <script src="https://unpkg.com/vue@next"></script>

    <div id="root"></div>

    <script>
      const app = Vue.createApp({
        data() {
          return {
            listArr: ["hello", "yunmu", "teacher"],
            listObj: {
              firstName: "yun",
              lastName: "mu",
              job: "teacher",
            },
          };
        },

        methods: {
          handleAddBtnClick(event) {
            console.log(event);
            // 使用数组的变更函数 push pop unshift shift reverse sort splice
            //this.listArr.push("hello");
            //this.listArr.pop();
            //this.listArr.unshift("study");
            //this.listArr.shift();
            //this.listArr.reverse();

           
          },
        },

        template: `
                <div>
                    <p v-for="(item, index) in listArr" :key="index">{{item}} --- {{index}}</p>
                    <button @click="handleAddBtnClick($event,1,2)">增加</button>    
                </div>
            `,
      });

      const vm = app.mount("#root");
    </script>
  </body>
</html>
